import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class FileUtil {
	public static List<Ticket> readTicketConf() {
		File file = new File("ticket.conf");
		BufferedReader reader = null;
		List<Ticket> result = new ArrayList<Ticket>();
		try {
			reader = new BufferedReader(new FileReader(file));
			String text = null;
			while ((text = reader.readLine()) != null) {
				String[] info = text.split(";");
				Ticket ticket = new Ticket(info[0], info[1], info.length == 2 ? "" : info[2]);
				result.add(ticket);
				System.out.println("one:" + ticket.getPassenger_name() + "; " + ticket.getPassenger_cardno() + "; " + ticket.getPassenger_mobileno());
			}
		} catch (FileNotFoundException e) {
			System.out.println("File not find!");
		} catch (IOException e) {
			System.out.println("File read Exception!");
		} finally {
			try {
				if (reader != null) {
					reader.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return result;
	}

	public static void read() throws IOException {
		File file = new File("order.xml");
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			String text = null;
			System.out.println(reader.toString());
			while ((text = reader.readLine()) != null) {
				
			}
		} finally {
			if (reader != null) {
				reader.close();
			}
		}
	}
	public static void main(String[] args) {
		System.out.println(System.getProperty("user.dir"));
		readTicketConf();
	}
}
